<%@page import="data.Rmi"%>
<jsp:useBean id="manager" scope="session" class="manager.Manager"></jsp:useBean>
<%
	manager.setListMedicament(Rmi.rechercheMedicament(null,0,20));
	String nom = "";
	if (request.getParameter("filtrer") != null) {
		
		boolean error = false;
		
		/* Recuperation des POST */
		nom = request.getParameter("nom");
		if (nom == null) nom = "";
		
		/* Verification des valeurs */
		if (nom.trim().equals("")) error = true;
	
		/* Traitement de la recherche si pas d'erreur */
		if (!error) {
			manager.setListMedicament(Rmi.rechercheMedicament(nom.equals("")?null:nom.trim(),0,10));
		}
	}
%>

<table>
	<tr>
		<td></td>
		<td>Nom</td>
		<td>Posologie standard</td>
	</tr>
	<%
	for(int i=0;i<manager.getListMedicament().size();i++){
		out.println("<tr>");
		out.print("<td><form action=\"modifPrescription.jsp\" method=\"post\">");
		out.print("<input type=\"hidden\" value=\""+i+"\" name=\"indexMedicament\" />");
		out.println("<input type=\"submit\" value=\"Selectionner\" /></form></td>");
		out.println("<td>"+manager.getListMedicament().get(i).getNom()+"</td>");
		out.println("<td>"+manager.getListMedicament().get(i).getPosologieStandard()+"</td>");
		out.println("</tr>");
	}
	%>
</table>